Step 17: Test a POST request
Update tests/routes/bookmakrs.test.js
and add the following test:
it("POST a bookmark", async () => {
const title = faker.lorem.sentence();
const url = faker.internet.url();
const response = await request.post("/bookmarks").send({
title,
url,
});
expect(response.status).toBe(201);
expect(response.body.data.id).toBeDefined();
expect(response.body.data.title).toBe(title);
expect(response.body.data.url).toBe(url);
});
Run the tests in this file.
Save and commit all changes.